Skip to content

Conversation

jasonyuezhang
Copy link
Owner

It's already prevented in the UI when the flag is enabled


Copied from getsentry#101177
Original PR: getsentry#101177

Copy link

Block Creation of Transaction-Based Alerts via API When Flag is Enabled

This PR prevents users from creating transaction alerts via the API by raising a validation error when the organizations:discover-saved-queries-deprecation feature flag is enabled. The enforcement, previously implemented in the UI, is now mirrored in backend validation to ensure users cannot circumvent the restriction through API usage. Additional backend and serializer tests ensure correct error messaging and validation for deprecated datasets.

Key Changes

• Added validation in SnubaQueryValidator._validate_performance_dataset to reject transactions and generic_metrics datasets if the organizations:discover-saved-queries-deprecation flag is active
• Updated tests in tests/sentry/incidents/endpoints/test_organization_alert_rule_index.py to assert correct error handling for deprecated datasets via the API
• Added new tests in tests/sentry/incidents/endpoints/test_serializers.py to confirm serializer-level rejections with feature flag enabled

Affected Areas

src/sentry/snuba/snuba_query_validator.py (dataset validation logic)
tests/sentry/incidents/endpoints/test_organization_alert_rule_index.py (API endpoint test coverage)
tests/sentry/incidents/endpoints/test_serializers.py (serializer behavior test coverage)

This summary was automatically generated by @propel-code-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants